package com.lzs.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lzs.entity.LoginLog;
import com.lzs.entity.OperationLog;
import com.lzs.system.mapper.OperationLogMapper;
import com.lzs.system.service.OperationLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 操作日志 服务实现类
 * </p>
 *
 * @author ymw
 * @since 2020-12-09
 */
@Service
public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, OperationLog> implements OperationLogService {
    @Autowired
    private OperationLogMapper operationLogMapper;
    @Override
    public Page<OperationLog> selectOperaAll(Integer page, Integer limit, Map map) {
        Page<OperationLog> operationLogPage=new Page<>(page,limit);

        String logName=(String) map.get("logName");
        String beginTime=(String) map.get("beginTime");
        String endTime=(String) map.get("endTime");
        String logType = (String) map.get("logType");

        QueryWrapper<OperationLog> queryWrapper=new QueryWrapper<>();
        if (StringUtils.isNotEmpty(logName)){
            queryWrapper.like("log_name",logName);
        }
        if (StringUtils.isNotEmpty(beginTime)){
            queryWrapper.gt("create_time",beginTime);
        }
        if (StringUtils.isNotEmpty(endTime)){
            queryWrapper.lt("create_time",endTime);
        }
        if (StringUtils.isNotEmpty(logType)){
            queryWrapper.eq("log_type",logType);
        }
        operationLogMapper.selectPage(operationLogPage,queryWrapper);
        return operationLogPage;
    }
}
